/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Initial Developer of the Original Code is
*   Nick Kreeger
* Portions created by the Initial Developer are Copyright (C) 2006-2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*   Nick Kreeger <nick.kreeger@park.edu>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

#ifndef __MailWindowController_h_  // remove?
#define __MailWindowController_h_

#import <Cocoa/Cocoa.h>
#import "CHBrowserView.h"
#import "BrowserWrapper.h"
#import "MessageWindowService.h"
#import "MessageHeaderView.h"

class CHMsgService;

@class MailboxesOutlineView;
@class MailboxesDataSource;
@class MessageListDataSource;
@class MessageHeaderView;
@class AttachmentView;
@class MailboxItem;
@class DummyMessageHeader;

@class BrowserWrapper;
@class BrowserTabView;
@class BrowserTabViewItem;
@class BrowserContentView;

@class MessageViewContainer;  // temp class.
@class GradientSplitView;

typedef enum
{
  eNewTabEmpty,
  eNewTabAboutBlank,
  eNewTabHomepage
  
} ENewTabContents;

typedef enum
{
  eAppendTabs,
  eReplaceTabs,
  eReplaceFromCurrentTab
  
} ETabOpenPolicy;

@interface MailWindowController : NSWindowController <BrowserUIDelegate,
                                                      MessageWindowDelegate,
                                                      MessageDataDelegate>
{
  IBOutlet MailboxesOutlineView* mMailboxesOutlineView;
  IBOutlet NSTableView*          mMessagesTableView;
  IBOutlet GradientSplitView*    mMessageSplitView;
  IBOutlet GradientSplitView*    mMailWindowSplitView;
  
  // Browser view stuff:
  IBOutlet BrowserTabView*       mTabBrowser;
  IBOutlet BrowserContentView*   mContentView;
  IBOutlet NSMenu*               mTabMenu;
  IBOutlet MessageViewContainer* mBrowserView;
  
  IBOutlet NSProgressIndicator*  mProgressBar;
  IBOutlet NSTextField*          mNumMessagesField;
  IBOutlet NSTextField*          mNumUnreadMessagesField;

  // This needs to be built dynamically.
  IBOutlet NSMenu*               mMessagesTableViewMenu;
  
  CHBrowserView*                 mCHBrowserView;
  
  MessageListDataSource*         mMessageListDataSource;
  MailboxesDataSource*           mMailboxesDataSource;
  
  MailboxItem*   mCurMailboxItem;
  NSTableColumn* mCurSelectedTableColumn;  // weak ref
  BOOL           mIsTransmitting;
  BOOL           mShouldAutosave;
  BOOL           mIsGettingNewMail;
  BOOL           mShouldRefreshFolder;
}

-(IBAction)newMailMessage:(id)sender;
-(IBAction)deleteMail:(id)sender;
-(IBAction)reply:(id)sender;
-(IBAction)replyAll:(id)sender;
-(IBAction)foward:(id)sender;
-(IBAction)sendReceive:(id)sender;
-(IBAction)stop:(id)sender;
-(IBAction)reloadMessage:(id)sender;
-(IBAction)openAddressBook:(id)sender;

-(IBAction)markSelectedMessagesRead:(id)sender;
-(IBAction)markSelectedMessagesUnread:(id)sender;
-(IBAction)markSelectedMessagesFlagged:(id)sender;
-(IBAction)markSelectedMessagesUnflagged:(id)sender;

-(IBAction)setViewLayout:(id)sender;

-(void)refreshMessageList;

-(void)selectMessageIndexes:(NSIndexSet*)aIndexSet;
-(void)scrollMessagesToSelectRow:(unsigned int)aRowSelect;

/**
 * Returns the applications transmission state. 
 * @return If the application is transmitting or not.
 */
-(BOOL)isTransmitting;

/**
 * Get the account key of the current selected folder from
 * the mailboxes outline view.
 * @return The account key that corresponds with the selected
 *         folder in the outline view, or nil if a folder 
 *         is not currently selected.
 */
-(NSString*)selectedAccountKey;

// Browser methods:
-(BrowserTabView*)getTabBrowser;
-(BrowserWrapper*)getBrowserWrapper;
-(void)createNewTab:(ENewTabContents)contents;
-(BrowserTabViewItem*)createNewTabItem;
-(void)openNewTabWithURL:(NSString*)aURLSpec referrer:(NSString*)aReferrer loadInBackground:(BOOL)aLoadInBG 
             allowPopups:(BOOL)inAllowPopups setJumpback:(BOOL)inSetJumpback;

// Gecko callback methods:
-(void)willShowPromptForBrowser:(BrowserWrapper*)inBrowser;
-(void)didDismissPromptForBrowser:(BrowserWrapper*)inBrowser;


-(BOOL)shouldEnableItemWithSelector:(SEL)aSelector;

@end


/**
 * For 0.2, provide a simple, gray colored status bar that matches our 
 * split panes. After 0.2, something cool like a gradient would be
 * very nice.
 */
@interface StatusBarView : NSView
@end

#endif
